package com.itheima;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class CollectionDemo {
    public static void main(String[] args) {
test1();
    }
    public static void test0(){
        List<String>list=new ArrayList<>();
        Collections.addAll(list,"张三","李四","王五","赵六");
        list.forEach(System.out::println);
//打乱顺序
        Collections.shuffle(list);
        list.forEach(System.out::println);

    }
    public static void test1() {
        List<Integer> list = new ArrayList<>();
        Collections.addAll(list, 1, 2, 3, 4, 5);
        Collections.shuffle(list);
        list.forEach(System.out::println);
        Collections.sort(list,((o1, o2) -> {
            return o2-o1;
        }));
        System.out.println("----------");
        list.forEach(System.out::println);

        System.out.println("---------------------");
        List<Student>list1=new ArrayList<>();
        list1.add(new Student("赵六",22));
        list1.add(new Student("张三",20));
        list1.add(new Student("李四",18));
        Collections.sort(list1);
        list1.forEach(System.out::println);
        List<Integer>synchronizedList=Collections.synchronizedList(list);


    }}